﻿<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<title>医院</title>
<link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<!-- Custom Css -->
<link href="assets/css/main.css" rel="stylesheet">
<link href="assets/css/login.css" rel="stylesheet">

<!-- Swift Themes. You can choose a theme from css/themes instead of get all themes -->
<link href="assets/css/themes/all-themes.css" rel="stylesheet" />
    <!--layui使用-->
    <script src="https://lib.baomitu.com/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://lib.baomitu.com/layui/2.6.5/layui.min.js"></script>
    <link href="https://lib.baomitu.com/layui/2.6.5/css/layui.min.css" rel="stylesheet">
</head>

<body class="login-page authentication">
<div class="container">
    <div class="card-top"></div>
    <div class="card">
        <h1 class="title"><span>医院</span>忘记密码? <div class="msg">在下面输入您的身份证号以重置您的密码</div></h1>
        <div class="col-md-12">
        <div class="col-md-12">
            <form>
                <div class="input-group"> <span class="input-group-addon"> <i class="zmdi zmdi-account"></i> </span>
                    <div class="form-line">
                        <input type="text" class="form-control" id="uid" placeholder="请输入您的要修改的账号" required autofocus>
                    </div>
                </div>

                <div class="input-group"> <span class="input-group-addon"> <i class="zmdi zmdi-account-box-phone"></i> </span>
                    <div class="form-line">
                        <input type="text" class="form-control" id="idcard" placeholder="请输入您的身份证号" required autofocus>
                    </div>
                </div>
                <div class="input-group"> <span class="input-group-addon"> <i class="zmdi zmdi-lock"></i> </span>
                    <div class="form-line">
                        <input type="password" class="form-control" id="pwd1"  placeholder="请输入新的密码"   >
                    </div>
                </div>

                <div class="input-group"> <span class="input-group-addon"> <i class="zmdi zmdi-lock"></i> </span>
                    <div class="form-line">
                        <input type="password" class="form-control" id="pwd2"    placeholder="请确认您的新密码"   >
                    </div>
                </div>

                <div class="row">                    
                    <div class="col-sm-12 text-center">
                        <a id="log_in" class="btn btn-raised waves-effect g-bg-cyan">重置密码</a>
                    </div>
                    <div class="col-sm-12 text-center"> <a href="sign-in.html">登录</a> </div>
                </div>
            </form>
        </div>
    </div>    
</div>

<div class="theme-bg"></div>
<!-- Jquery Core Js --> 
<script src="assets/bundles/libscripts.bundle.js"></script> <!-- Lib Scripts Plugin Js -->
<script src="assets/bundles/vendorscripts.bundle.js"></script> <!-- Lib Scripts Plugin Js --> 

<script src="assets/bundles/mainscripts.bundle.js"></script><!-- Custom Js -->
</body>
</html>

<script>
    $("#log_in").click(function () {
        var uid = $("#uid").val();
        var idcard = $("#idcard").val();
        var pwd1 = $("#pwd1").val();
        var pwd2 = $("#pwd2").val();

        if (uid == null || uid === '') {
            layer.open({
                title: '错误提示'
                , content: '用户名不能为空'
                , icon: 2
            })
            return false;
        }

        if (idcard == null || idcard === '') {
            layer.open({
                title: '错误提示'
                , content: '身份证号不能为空'
                , icon: 2
            })
            return false;
        }
        if (pwd1 == null || pwd1 === '') {
            layer.open({
                title: '错误提示'
                , content: '密码不能为空'
                , icon: 2
            })
            return false;
        }
        if (pwd2 == null || pwd2 === '') {
            layer.open({
                title: '错误提示'
                , content: '密码不能为空'
                , icon: 2
            })
            return false;
        }
        if (pwd1 !== pwd2) {
            layer.open({
                title: '错误提示'
                , content: '两次密码不一致，请确认密码'
                , icon: 2
            })
            return false;
        }


$.get("/ResetPwd/verification",{uid:uid,idcard:idcard},function (data) {
    if(data==true){
$.get("/ResetPwd/resetpassword",{uid:uid,idcard:idcard,password:pwd2},function (date) {
  if(date==true){
layer.confirm("密码修改成功,是否跳转到登录页",function () {
    window.location.href = "http://localhost:8080/ManagementEnd/sign-in.html";
})

  }else {
      layer.open({
          title: '提示'
          , content: '密码修改失败'
          , icon: 2
      })
  }
})
    }else {
        layer.open({
            title: '提示'
            , content: '账号或身份证号错误'
            , icon: 2
        })
        return false;
    }
})
    })
</script>